<template>
	 <image class="code-img" :src="src"  @click="getImg()"></image>
</template>

<script>
	 import {  api } from '@/app/api.js'  
	 export default {
	 	props: { 
	 		type: String, 
	 	}, 
		data(){
			 return {
				 src:null,
			 }
		}, 
		mounted() {
			  this.getImg() 
			 	  
		},
	 	methods: {
			getImg(){
				var url =this.type == 'login' ? "/getLoginImageCode":"/imageCaptchaImage";
				api(url,{},'GET').then(data=>{
					 console.log("data: ",data);
					this.src = "data:image/gif;base64," + data.img;
					this.$store.state.uuid =  data.uuid;
					console.log("this.uuid: ",data.uuid);
				})
			},
	 		 
	 	}
	 }
</script>

<style lang="less"> 
	.code-img{
		height:30px;
		width: 100px;
	} 
</style>
